package com.lixueju.security.box.core.redis;

import lombok.Data;

/**
 * redis锁对象
 */
@Data
public class RedisLock {

    private String lockName;    // 锁的名称
    private Long waitSeconds;   // 获取锁的等待时间
    private Long expireTime;    // 锁的过期时间

    // 默认获取锁的等待时间为60s 照顾慢sql
    private static final long DEFAULT_WAIT_LOCK_TIME_OUT = 60;

    // 默认锁的超时时间为60s 照顾慢sql
    private static final long DEFAULT_EXPIRE = 60;

    public RedisLock(String lockName, Long waitSeconds, Long expireTime) {
        this.lockName = lockName;
        this.waitSeconds = waitSeconds;
        this.expireTime = expireTime;
    }

    public RedisLock(String lockName, Long waitSeconds) {
        this.lockName = lockName;
        this.waitSeconds = waitSeconds;
        this.expireTime = DEFAULT_EXPIRE;
    }

    public RedisLock(String lockName) {
        this.lockName = lockName;
        this.waitSeconds = DEFAULT_WAIT_LOCK_TIME_OUT;
        this.expireTime = DEFAULT_EXPIRE;
    }
}
